import 'dart:math';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/task/main/models/com/com.dart';
import 'package:leader_help/page/task/subs/com_list/index.dart';
import 'package:leader_help/utils/util.dart';

class ComListCell extends GetView<ComListController> {
  const ComListCell({Key? key, required this.mod}) : super(key: key);
  final ComModel mod;
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () => controller.actionCell(mod),
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 10.r),
        height: 120.r,
        child: ClipRRect(
          borderRadius: BorderRadius.circular(6.r),
          child: Container(
            color: Colors.white,
            child: Stack(
              children: [
                Row(
                  children: [
                    Container(
                      width: 60.r,
                      margin: EdgeInsets.symmetric(horizontal: 5.r),
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(3.r),
                      ),
                      child: loadImage(url: mod.icon, fit: BoxFit.contain),
                    ),
                    Expanded(
                      child: SizedBox(
                        height: 100.r,
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          children: [
                            Text(
                              mod.title,
                              style: pfSCStyle(
                                  color: ColorsUtil.title, fontSize: 15.sp),
                            ),
                            Row(
                              children: [
                                Container(
                                  color: ColorsUtil.bg,
                                  padding: EdgeInsets.symmetric(
                                      horizontal: 3.r, vertical: 2.r),
                                  child: Text(
                                    mod.address,
                                    style: pfMediumStyle(
                                        color: ColorsUtil.subTitle,
                                        fontSize: 12.sp),
                                  ),
                                ),
                                SizedBox(
                                  width: 10.r,
                                ),
                                Wrap(
                                  spacing: 10.r,
                                  children: mod.signs
                                      .map((e) => Container(
                                            color: ColorsUtil.pink,
                                            padding: EdgeInsets.symmetric(
                                                horizontal: 3.r, vertical: 2.r),
                                            child: Text(
                                              e,
                                              style: pfMediumStyle(
                                                  color: ColorsUtil.red,
                                                  fontSize: 12.sp),
                                            ),
                                          ))
                                      .toList(),
                                )
                              ],
                            ),
                            Row(
                              children: [
                                Icon(
                                  Icons.info,
                                  color: ColorsUtil.orange,
                                  size: 18.r,
                                ),
                                Text(
                                  '需要定方案作安排',
                                  style: pfMediumStyle(
                                      color: ColorsUtil.orange,
                                      fontSize: 14.sp),
                                ),
                              ],
                            )
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
                Positioned(
                  right: 0,
                  child: Visibility(
                    visible: mod.level == 1,
                    child: Transform(
                      transform: Matrix4.rotationZ(pi / 4),
                      origin: Offset(80.r, 50.r),
                      child: Container(
                        color: const Color(0xff00C9B0),
                        width: 60.r,
                        height: 60.r,
                        alignment: Alignment.bottomCenter,
                        child: Text(
                          '重点',
                          style: pfMediumStyle(
                              color: Colors.white, fontSize: 12.sp),
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
